

class hunman:
    def __init__(self,name):
        self.name=name

    def job(self):
        print('My job is SW engineer')

    def wealth(self):
        print('my wealth is XXX')

    def belief(self):
        print('my belief is buddha')


h=hunman('Tolle')
# check if has job attribute
print(hasattr(h,'belief'))
print(hasattr(h,'name'))

# het attribute or func
getattr(h,'job')()
print(getattr(h,'name'))

# set attribute
setattr(hunman,'age','32') # 类级变量
print(getattr(h,'age'))
list1=dir(hunman)[-5:] # show all attribute
print(list1)


def energy():
    print('full energy')

setattr(h,'energy',energy)
print(dir(h)[-6:])


# delete attribute
delattr(h,'name')
print(dir(h)[-5:])
delattr(h,'energy')
print((dir(h)[-4:]))